import java.awt.Color;
import java.awt.Graphics2D;


public class Bullet implements Paintable{

        private double x;
        private double y;
        private Environment e;
        private double vx;
        private double vy;
        private int r=2;
        private int v=10;
        private double theta;

        /**
         * @param x x location of bullet
         * @param y y location of bullet
         * @param e Environment
         * @param theta direction of bullet flight path
         */
        public Bullet(int x, int y,double theta,Environment e){
                this.x=x;
                this.y=y;
                this.e=e;
                e.settBullets((e.gettBullets()+1));
                //System.out.println(e.gettBullets());
                this.theta=theta;
                double vx=(this.v*Math.sin(theta));
                double vy=(this.v*Math.cos(theta));
                this.vx=vx;
                this.vy=vy;
        }
        public void Paint(Graphics2D g){
                g.setColor(new Color(255,0,0));
                g.drawOval((int)this.x-r, (int)this.y-r, r*2, r*2);
        }

        public void act(){
                this.x=this.x+vx;
                this.y=this.y+vy;
                if(this.x<0||this.y<0||this.x>e.getWidth()||this.y>e.getHeight()) e.getbList().remove(this);
        }

        /**
         * @return the x
         */
        public int getX() {
                return (int)x;
        }

        /**
         * @param x the x to set
         */
        public void setX(int x) {
                this.x = x;
        }

        /**
         * @return the y
         */
        public int getY() {
                return (int)y;
        }

        /**
         * @param y the y to set
         */
        public void setY(int y) {
                this.y = y;
        }

        /**
         * @return the vx
         */
        public int getVx() {
                return (int)vx;
        }

        /**
         * @param vx the vx to set
         */
        public void setVx(int vx) {
                this.vx = vx;
        }

        /**
         * @return the vy
         */
        public int getVy() {
                return (int)vy;
        }

        /**
         * @param vy the vy to set
         */
        public void setVy(int vy) {
                this.vy = vy;
        }

        /**
         * @return the theta
         */
        public double getTheta() {
                return theta;
        }

        /**
         * @param theta the theta to set
         */
        public void setTheta(double theta) {
                this.theta = theta;
        }
        /**
         * @return the r
         */
        public int getR() {
                return r;
        }
        /**
         * @param r the r to set
         */
        public void setR(int r) {
                this.r = r;
        }


}
